package com.lap.framework.common.enums;

import java.util.Objects;
import lombok.Getter;
import lombok.ToString;

@ToString
@Getter
public enum BoolEnum implements BaseEnum<Integer> {
  NO(0, "否"),
  YES(1, "是"),
  ;

  private final Integer code;
  private final String labelZh;

  BoolEnum(Integer code, String labelZh) {
    this.code = code;
    this.labelZh = labelZh;
  }

  /** 根据code获取枚举 */
  public static BoolEnum of(Integer code) {
    if (code == null) return null;
    for (BoolEnum value : values()) {
      if (Objects.equals(value.code, code)) return value;
    }
    return null;
  }

  /** 判断是否为"是" */
  public boolean isYes() {
    return this == YES;
  }

  /** 判断是否为"否" */
  public boolean isNo() {
    return this == NO;
  }
}
